<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class penerimaan_uptd_per_hari extends My_Controller {

	function __construct()
	{
		parent::__construct();
		$this->load->model('mdl_penerimaan_uptd_per_hari', 'penerimaan_uptd_per_hari');
		$this->load->library('pdf'); 
	}
	
	 function index()
	{
		$data['can_view'] 	= $this->can_view();
		$data['can_insert'] = $this->can_insert();
		$data['can_update'] = $this->can_update();
		$data['can_delete'] = $this->can_delete();
		
		$this->open();
		
		$periode 	= $this->input->post('periode');
		$kode_wil 	= $this->input->post('kode_wil');
		$jenis_kb 	= $this->input->post('jenis_kb');

		$data['periode'] = $this->input->post('periode');
		$data['results'] = $this->penerimaan_uptd_per_hari->getItem($periode, $kode_wil, $jenis_kb);
		$data['piutang'] = $this->penerimaan_uptd_per_hari->piutang($periode, $kode_wil, $jenis_kb);
		$data['sudah_bayar'] = $this->penerimaan_uptd_per_hari->sudah_bayar($periode, $kode_wil, $jenis_kb);
		$data['getItemCount'] = $this->penerimaan_uptd_per_hari->getItemCount($periode, $kode_wil, $jenis_kb);
		$data['kode_wil'] = $this->penerimaan_uptd_per_hari->getKodeWil();
		$data['jenis_kb'] = $this->penerimaan_uptd_per_hari->getJenisKB();
		$this->load->view('penerimaan_uptd_per_hari/list_penerimaan_uptd_per_hari',$data); 
        
		$this->close();
	} 
	
	function grid($periode=0, $kode_wil=null, $jenis_kb=null){
		$kode_wil=str_replace("%20", " ", $kode_wil);
		$jenis_kb=str_replace("%20", " ", $jenis_kb);
		echo $this->penerimaan_uptd_per_hari->getItemGrid($periode, $kode_wil, $jenis_kb);
	}
	
	public function report_pdf_preview()
	{
		$periode = $this->uri->segment('3');
		$kode_wil = $this->uri->segment('4'); 
		$jenis_kb = $this->uri->segment('5'); 
		$data['periode'] 		= $periode; 
		$data['kode_wil'] 		= $kode_wil;
		$data['jenis_kb'] 		= $jenis_kb;
		if ($kode_wil == 'all')
			{$data['kode_wilvalue']		= "SEMUA WILAYAH";}
		else
			{	
				$a 							= $this->penerimaan_uptd_per_hari->getKodeWilValue($kode_wil);
				$data['kode_wilvalue']		= $a[0]['nm_wilayah'];
			}
			
		if ($jenis_kb == 'all')
			{$data['jenis_kbvalue']		= "SEMUA JENIS KENDARAAN";}
		else
			{	
				$b 							= $this->penerimaan_uptd_per_hari->getJenisKBValue($jenis_kb);
				$data['jenis_kbvalue']		= $b[0]['uraian'];
			} 
		$data['results'] = $this->penerimaan_uptd_per_hari->getItem($periode, $kode_wil, $jenis_kb);
		$data['piutang'] = $this->penerimaan_uptd_per_hari->piutang($periode, $kode_wil, $jenis_kb);
		$data['sudah_bayar'] = $this->penerimaan_uptd_per_hari->sudah_bayar($periode, $kode_wil, $jenis_kb);
		$data['getItemCount'] = $this->penerimaan_uptd_per_hari->getItemCount($periode, $kode_wil, $jenis_kb);
		
		
		$this->load->view('penerimaan_uptd_per_hari/print_penerimaan_uptd_per_hari_preview', $data);  
	}
	
	public function report_pdf_langsung()
	{
		$periode = $this->uri->segment('3');
		$kode_wil = $this->uri->segment('4'); 
		$jenis_kb = $this->uri->segment('5'); 
		
		$data['periode'] 		= $periode; 
		$data['kode_wil'] 		= $kode_wil;
		$data['jenis_kb'] 		= $jenis_kb;
		 
		$data['kirim']	= 	$this->uri->segment('6'); 
		
		$pieces = explode("~", $data['kirim']); 
		/*
		$data['buat_nama'] 			= $this->input->post('buat_nama');
		$data['buat_nip'] 			= $this->input->post('buat_nip');
		$data['buat_jabatan'] 		= $this->input->post('buat_jabatan');
		
		$data['periksa_nama'] 		= $this->input->post('periksa_nama');
		$data['periksa_nip'] 		= $this->input->post('periksa_nip');
		$data['periksa_jabatan'] 	= $this->input->post('periksa_jabatan');
		
		$data['ketahui_nama'] 		= $this->input->post('ketahui_nama');
		$data['ketahui_nip'] 		= $this->input->post('ketahui_nip');
		$data['ketahui_jabatan'] 	= $this->input->post('ketahui_jabatan');
		*/
		$data['buat_nama'] 			= $pieces[0];
		$data['buat_nip'] 			= $pieces[1];
		$data['buat_jabatan'] 		= $pieces[2];
		
		$data['periksa_nama'] 		= $pieces[3];
		$data['periksa_nip'] 		= $pieces[4];
		$data['periksa_jabatan'] 	= $pieces[5];
		
		$data['ketahui_nama'] 		= $pieces[6];
		$data['ketahui_nip'] 		= $pieces[7];
		$data['ketahui_jabatan'] 	= $pieces[8];
		
		$data['hard']	= '----';
		if ($kode_wil == 'all')
			{$data['kode_wilvalue']		= "SEMUA WILAYAH";}
		else
			{	
				$a 							= $this->penerimaan_uptd_per_hari->getKodeWilValue($kode_wil);
				$data['kode_wilvalue']		= $a[0]['nm_wilayah'];
			}
			
		if ($jenis_kb == 'all')
			{$data['jenis_kbvalue']		= "SEMUA JENIS KENDARAAN";}
		else
			{	
				$b 							= $this->penerimaan_uptd_per_hari->getJenisKBValue($jenis_kb);
				$data['jenis_kbvalue']		= $b[0]['uraian'];
			} 
		$data['results'] = $this->penerimaan_uptd_per_hari->getItem($periode, $kode_wil, $jenis_kb);
		$data['piutang'] = $this->penerimaan_uptd_per_hari->piutang($periode, $kode_wil, $jenis_kb);
		$data['sudah_bayar'] = $this->penerimaan_uptd_per_hari->sudah_bayar($periode, $kode_wil, $jenis_kb);
		$data['getItemCount'] = $this->penerimaan_uptd_per_hari->getItemCount($periode, $kode_wil, $jenis_kb);
		 
		$file_pdf = $this->load->view('penerimaan_uptd_per_hari/print_penerimaan_uptd_per_hari_langsung', $data ,TRUE);  
		//$this->load->view('penerimaan_uptd_per_hari/print_penerimaan_uptd_per_hari_langsung', $data);  
		$this->pdf->pdf_create($file_pdf,'Laporan'); 
	}
	
}
 